﻿using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Linq;
using System.Text;
using System.Windows.Forms;

namespace DapperExTest
{
    public partial class Form1 : Form
    {
        public Form1()
        {
            InitializeComponent();
            //ucPagerControl21.ShowSourceChanged += UcPagerControl21_ShowSourceChanged;

        }
        private void UcPagerControl21_ShowSourceChanged(object currentSource)
        {
            dataGridView1.DataSource = currentSource;
            //设置列头不可点击
            /*  foreach (var item in dataGridView1.Columns)
              {
                  this.dataGridView1.Columns[item.ToString()].SortMode = DataGridViewColumnSortMode.NotSortable;
              }*/
            /*  for (int i = 0; i < dataGridView1.Columns.Count; i++)
              {
                  this.dataGridView1.Columns[i]. = DataGridViewColumnSortMode.NotSortable;
              }*/
            //
          /*  for (int i = 0; i < this.dataGridView1.Rows.Count; i++)
            {
                for (int j = 0; j < this.dataGridView1.Columns.Count; j++)
                {
                    //MessageBox.Show(this.dataGridView1.Rows[i].Cells[j].Value.ToString());
                    //this.dataGridView1.Rows[i].Cells[j].Value = "";
                    if (this.dataGridView1.Rows[i].Cells[j].Value == null)
                    {
                        break;
                    }

                    //获得单元格数据查询条件
                    string v = this.dataGridView1.Rows[i].Cells[j].Value.ToString();
                    if (v != "")
                    {
                        //string[] vArr = v.Split(' ');

                        string[] vArr = v.Split(new string[] { " " }, StringSplitOptions.RemoveEmptyEntries);
                        int z = Convert.ToInt32(vArr[0].ToString());
                        int a = Convert.ToInt32(vArr[1].ToString());
                        int b = Convert.ToInt32(vArr[2].ToString());
                        string c = vArr[4].ToString();
                        Index_DB idb = idblist.Where(p => p.zu == z && p.a == a && p.b == b && p.c == c).FirstOrDefault();
                        if (idb == null)
                            continue;
                        this.dataGridView1.Rows[i].Cells[j].Value = idb.zu.ToString() + "  " + idb.a.ToString() + "  " + idb.b.ToString() + " — " + idb.c.ToString();
                        if (Convert.ToInt32(idb.Font) == 0)
                        {
                            this.dataGridView1.Rows[i].Cells[j].Style.Font = new Font("", 18, FontStyle.Regular);
                        }
                        else
                        {
                            this.dataGridView1.Rows[i].Cells[j].Style.Font = new Font("", 18, FontStyle.Bold);
                        }
                    }

                }

            }*/
        }
    }
}
